package com.neusoft.ch10.collections;

public class Student2 implements Comparable<Student2> {

	// 属性
	private String stuName;
	private String stuNo;
	private int stuScore;

	public Student2(String stuName, String stuNo, int stuScore) {
		super();
		this.stuName = stuName;
		this.stuNo = stuNo;
		this.stuScore = stuScore;
	}

	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getStuNo() {
		return stuNo;
	}

	public void setStuNo(String stuNo) {
		this.stuNo = stuNo;
	}

	public int getStuScore() {
		return stuScore;
	}

	public void setStuScore(int stuScore) {
		this.stuScore = stuScore;
	}

	@Override
	public String toString() {
		return "Student2 [stuName=" + stuName + ", stuNo=" + stuNo + ", stuScore=" + stuScore + "]";
	}

	@Override
	public int compareTo(Student2 stu) {
		// 要求返回三类值：大于0，等于0，小于0
		// 根据业务逻辑，比较标准是按成绩高低排序
		// 比较结果
		int result = 0;
		// stu1成绩>stu2成绩
		if (stu != null) {
			// 大于
			if (this.getStuScore() > stu.getStuScore()) {
				result = 1;
			} else if (this.getStuScore() < stu.getStuScore()) {
				// 小于
				result = -1;
			} else {
				result = 0;
			}
		}
		// 返回值
		return result;
	}

	
}
